#include <QtGui/QApplication>
#include "MainWindow.h"
#include "ThreadCliente.h"

#include <QThread>

int main(int argc, char *argv[])
{
	QString ip( "127.0.0.1" );

	const unsigned short porta = 8763;

	QApplication a(argc, argv);
	MainWindow *w = new MainWindow();
	ThreadCliente *c = new ThreadCliente(ip, porta, w);
	QThread *thread = new QThread();

	if( argc > 1 )
	{
		ip = argv[1];
	}

	QObject::connect( thread, SIGNAL(terminated()), thread, SLOT(deleteLater()) );
	QObject::connect( thread, SIGNAL(started()), c, SLOT(init()));

	c->moveToThread( thread );

	thread->start();

	w->show();

	return a.exec();
}
